package Agente;

import jade.content.lang.sl.SLCodec;
import jade.domain.DFService;
import jade.domain.FIPAException;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;
import jade.lang.acl.ACLMessage;



public class AgenteQueSoRespondeABemEducados extends jade.core.Agent {
	
	
	public void setup() {
		
		// REGISTO DO AGENTE NAS PAGINAS AMARELAS
		DFAgentDescription dfd = new DFAgentDescription();
        dfd.setName( getAID() ); 
        ServiceDescription sd  = new ServiceDescription();
        sd.setType( "agente_respondao" );
        sd.setName( getLocalName() );
        dfd.addServices(sd);
        
        try {  
            DFService.register(this, dfd );  
        }
        catch (FIPAException fe) { fe.printStackTrace(); }
		// *************
		
		
        System.out.println("Tou a escuta!");
		ACLMessage msg = blockingReceive();
		System.out.println("Parou a escuta!\n");
		
		
		System.out.println("Recebi isto -> " + msg.getContent());		
		
//		ACLMessage reply = new ACLMessage( ACLMessage.INFORM );
//	    reply.setContent( "Pong" );
//	    reply.addReceiver( msg.getSender() );
//	    send(reply);
		
	}

}
